class User < ActiveRecord::Base

  def email_empty?
    email != ""
  end

	validates_presence_of :name, :firstname,:password,:username,:email, :message => "must be specified"
	
	validates_confirmation_of :password, :message => "is not the same"

	validates_uniqueness_of :username, :email , :message => "already present"
	
	
	validates_format_of :email, :if => :email_empty? ,:with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/, :message => "is invalid"
	

	has_many :private_messages
	
	has_attached_file :photo, :styles => {:small => "150x150>" }
	
	validates_attachment_size :photo, :less_than => 5.megabytes
	validates_attachment_content_type :photo, :content_type => ['image/jpeg','image/png']
end